﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using STLGROUP.Layers.Common;

namespace STLGROUP.Layers.DataAccessLayers
{
    partial class DT_SanPham
    {
        public Image TrackingState
        {
            get
            {
                Image img = null;
                switch (this.EntityState)
                {
                    case System.Data.EntityState.Added:
                    case System.Data.EntityState.Detached:
                        img = (Image)Properties.Resources.status_added;
                        img.Tag = STLGROUP.Layers.Common.StructsEnums.EnumEntityState.Added;
                        break;
                    case System.Data.EntityState.Deleted:                        
                        img = (Image)Properties.Resources.status_deleted;
                        img.Tag = STLGROUP.Layers.Common.StructsEnums.EnumEntityState.Deleted;
                        break;
                    case System.Data.EntityState.Unchanged:
                        img = (Image)Properties.Resources.status_unchanged;
                        img.Tag = STLGROUP.Layers.Common.StructsEnums.EnumEntityState.Unchanged;
                        break;
                    case System.Data.EntityState.Modified:    
                        if (IDTrangThaiSanPham == (int?)StructsEnums.EnumTrangThaiSanPham.Huy)
                        {
                            img = (Image)Properties.Resources.status_deleted;
                        }
                        else
                        {
                            img = (Image)Properties.Resources.status_modified;
                            img.Tag = STLGROUP.Layers.Common.StructsEnums.EnumEntityState.Modified;
                        }

                        break;
                }

                return img;
            }
        }

        public int SoLuongNhapThem
        {
            get;
            set;
        }

        public int? SoLuongDat
        {
            get;
            set;
        }

        /// <summary>
        /// Thanh tien dat hang
        /// </summary>
        public Decimal ThanhTien
        {
            get
            {
                if (GiaNhap.HasValue && SoLuongDat.HasValue)
                {
                    return SoLuongDat.Value * GiaNhap.Value;
                }

                return 0;
            }
        }

        public string TenDonViTinh
        {
            get;
            set;
        }
    }
}
